import {Injectable} from '@angular/core';
import {HttpUtilService} from "../../../../../services/http/http-util.service";
import {BarnSystemInfo} from "../entity/barn-system-info";
import {Observable} from "rxjs";

@Injectable({
  providedIn: 'root'
})
export class SystemInfoService {

  private uriPrefix = "/system/systemInfo"

  constructor(private http: HttpUtilService) {
  }

  /**
   * 保存数据
   * @param data 数据
   * @param handleError 是默认处理错误
   */
  save(data: BarnSystemInfo, handleError = true): Observable<BarnSystemInfo> {
    return this.http.post<BarnSystemInfo>(this.uriPrefix + "/save", data, handleError)
  }

  query(data: BarnSystemInfo, handleError = true): Observable<BarnSystemInfo[]> {
    return this.http.get(this.uriPrefix + "/query", handleError, data)
  }

  getById(id: string, handleError = true): Observable<BarnSystemInfo> {
    return this.http.get(this.uriPrefix + '/getById', handleError, {pid: id})
  }
}
